package cn.edu.tju.scs.leave.web;

import cn.edu.tju.scs.leave.dto.BizCode;
import cn.edu.tju.scs.leave.dto.ResponseCode;
import cn.edu.tju.scs.leave.entity.Menu;
import cn.edu.tju.scs.leave.entity.User;
import cn.edu.tju.scs.leave.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by haoxiaotian on 2016/9/4 20:38.
 */
@Controller
@RequestMapping("/mng")
public class MngController extends BaseController{

    @Autowired
    private MenuService menuService;

    @RequestMapping(method = RequestMethod.GET)
    public String index(HttpSession session,Model model){
        User user = (User) session.getAttribute("user");
        if(user == null){
            return "login";
        }
        else{
            List<Menu> menus = menuService.queryMenusByUserId(user.getId());
            session.setAttribute("menus", menus);
            return "index_dynamic";
        }
    }
}
